package com.zmn.mcc.services.interfaces.dept;

import com.zmn.mcc.common.constant.DpermitConsts;
import com.zmn.mcc.model.dto.dpermit.DpermitCountDO;
import com.zmn.mcc.common.dto.permit.DpermitLitDO;
import com.zmn.mcc.model.entity.dept.McDeptDpermit;
import com.zmn.mcc.model.entity.dept.McDeptDpermitQuery;

import java.util.List;

/**
 * @author heguanghua
 * @since 2020/04/14 14:07
 */
public interface DeptDpermitService {

    McDeptDpermit findByKey(Integer deptId, Integer dataType, Integer dataLevel, Integer dataId);
    McDeptDpermit findByKey(McDeptDpermit deptDpermit);

    McDeptDpermit findByQuery(McDeptDpermitQuery query);

    List<McDeptDpermit> listPageByQuery(McDeptDpermitQuery query);

    List<McDeptDpermit> listByDeptId(Integer deptId);
    List<McDeptDpermit> listByDeptIdAndDataType(Integer deptId, Integer dataType);
    List<McDeptDpermit> listByDeptIdAndDataAttr(Integer deptId, Integer dataType, Integer dataLevel);
    List<McDeptDpermit> listByDeptIdAndDataAttr(Integer deptId, Integer dataType, List<Integer> dataLevels);

    List<McDeptDpermit> listByQuery(McDeptDpermitQuery query);

    /**
     * 取得指定部门指定类型的数据权限ID集合
     * @param deptId 部门ID
     * @param dataType 数据权限类型 {@link DpermitConsts#TYPE_ORGANIZE}
     * @param dataLevels 指定等级
     * @return
     */
    List<Integer> listDataIdByDeptIdAndDataType(Integer deptId, Integer dataType);
    List<Integer> listDataIdByDeptIdAndDataAttr(Integer deptId, Integer dataType, Integer dataLevel);
    List<Integer> listDataIdByDeptIdAndDataAttr(Integer deptId, Integer dataType, List<Integer> dataLevels);
    List<Integer> listDataIdByQuery(McDeptDpermitQuery query);

    /**
     * 取得简化数据权限对象列表
     * @param deptId
     * @param dataType 数据权限类型 {@link DpermitConsts#TYPE_ORGANIZE}
     * @return
     */
    List<DpermitLitDO> listDpermitLitByStaffIdAndDataType(Integer deptId, Integer dataType);
    List<DpermitLitDO> listDpermitLitByQuery(McDeptDpermitQuery query);

    Integer countByQuery(McDeptDpermitQuery query);

    List<DpermitCountDO> countByQueryGroupByParentId(McDeptDpermitQuery query);


    Integer updateByKey(McDeptDpermit deptDpermit);

    Integer updateSubAllByQuery(McDeptDpermitQuery query);


    Integer insert(McDeptDpermit deptDpermit);

    Integer insertByBatch(List<McDeptDpermit> deptDpermits);


    Integer deleteByKey(Integer deptId, Integer dataType, Integer dataLevel, Integer dataId);
    Integer deleteByKey(McDeptDpermit deptDpermit);

    Integer deleteByDeptId(Integer deptId);
    Integer deleteByDeptIdAndDataType(Integer deptId, Integer dataType);
    Integer deleteByDeptIdAndDataAttr(Integer deptId, Integer dataType, List<Integer> dataLevels);
    Integer deleteByQuery(McDeptDpermitQuery query);
}
